import redis
from readConfig import ReadConfig
redis_conf = ReadConfig().get_section('redis')
host = redis_conf['host']
auth = redis_conf['auth']

class redisUitl:

    def __init__(self):
        pool = redis.ConnectionPool(host=host,port=6379,password=auth,max_connections=3)
        self.re = redis.Redis(connection_pool=pool)

    def remove(self,key):
        if self.re.exists(key):
            self.re.delete(key)

    def set_string(self,key,value):
        self.re.setnx(key,value)

    def set_expire(self,key,time):
        self.re.expire(key,time)
        print(self.re.ttl(key))


if __name__ == '__main__':
    re = redisUitl()
    re.set_expire('C2:login_user_password_error:limit:100120-12952',20)

